﻿<!DOCTYPE html>
<html>
<head>
    <script src="/js/header.js"></script>
    <link href="/lib/jquery/jquery-ui.min.css" rel="stylesheet" />
    <script src="/lib/jquery/jquery-ui.min.js"></script>
</head>
<body>
    <div class="data-wrap case" id="container">
        <div class="data-tool clearfix">
            <div class="pull-left form-inline ">
                <a class="btn btn-default" data-modal="/view/account/edit.html" data-title="新增" data-width="530" data-height="604"><span class="glyphicon glyphicon-plus"></span> 新增</a>
            </div>
            <div class="pull-right">
                <form class="form-inline" id="formSearch">

                    <div class="input-group">
                        <label class="input-group-addon m5_l">公司名称：</label>
                        <input class="form-control" name="uCompanyName" type="text" />
                    </div>

                    <div class="input-group">
                        <label class="input-group-addon m5_l">登陆名称：</label>
                        <input class="form-control" name="uLoginName" type="text" />
                    </div>

                    <div class="input-group">
                        <label class="input-group-addon m5_l">联络电话：</label>
                        <input class="form-control" name="uTelephone" type="text" />
                    </div>

                    <div class="input-group">
                        <label class="input-group-addon m5_l">状态：</label>
                        <select class="form-control" name="uStatus">
                            <option value="-1">请选择</option>
                            <option value="1">启用</option>
                            <option value="2">禁用</option>
                        </select>
                    </div>
                    <button type="button" class="btn btn-default" id="btnSearch"><span class="glyphicon glyphicon-search"></span> 搜索</button>
                </form>
            </div>
        </div>
        <div class="paging">
        </div>

    </div>
    <script type="text/x-dot-template" id="templatePager">
        <div class="data-head table-responsive">
            <table class="table">
                <thead>
                    <tr>
                        <th>登陆名称</th>
                        <th>联络电话</th>
                        <th>联络Email</th>
                        <th>公司名称</th>
                        <th>状态</th>
                        <th>谷歌验证</th>
                        <th>说明</th>
                        <th width="200">操作</th>
                    </tr>
                </thead>
            </table>
        </div>

        <div class="data-body data-scroll">
            <div class="data-div-view">
                <table class="table table-hover">
                    <tbody>
                        {{~it.tData :item:index}}
                        <tr>
                            <td>{{= item.uLoginName }}</td>
                            <td>{{= item.uTelephone }}</td>
                            <td>{{= item.uEmail }}</td>
                            <td>{{= item.uCompany.companyName }}</td>
                            <td>{{= FlashPay.Util.GetStatusValue(item.uStatus) }}</td>
                            <td>{{= FlashPay.Util.GetStatusValue(item.uLoggedIn) }}</td>
                            <td>{{= FlashPay.Util.GetShortStr(item.uDescription) }}</td>
                            <td width="200">
                                {{? item.uStatus==1 }}
                                <a class="btn btn-warning m5_l"
                                   data-confirm='"{{= item.uLoginName }}" <br>确定要<span style="color:#e38d13;">禁用</span>该账号吗？'
                                   data-href="/User/ChangeStatus?Id={{= item.uId}}&uStatus=2">禁用</a>
                                {{?? }}
                                <a class="btn btn-success m5_l"
                                   data-confirm='"{{= item.uLoginName }}" <br>确定要<span style="color:#419641;">启用</span>该账号吗？'
                                   data-href="/User/ChangeStatus?Id={{= item.uId}}&uStatus=1">启用</a>
                                {{? }}

                                {{? item.uStatus!=3 }}
                                <button type="button" class="btn btn-default m5_l" data-modal="/view/account/edit.html?id={{= item.uId}}" data-title="编辑 - {{= item.uLoginName }}" data-width="530" data-height="653">
                                    <span class="glyphicon glyphicon-edit"></span> 编辑
                                </button>
                                <a class="btn btn-danger m5_l" data-id="{{= item.uId}}"
                                   data-confirm='"{{= item.uLoginName }}" <br>确定要<span style="color:red;">删除</span>该账号吗？'
                                   data-href="/User/Delete?Id={{= item.uId}}"><span class="glyphicon glyphicon-trash"></span> 刪除</a>
                                {{? }}
                            </td>
                        </tr>
                        {{~}}
                    </tbody>
                </table>
            </div>
        </div>
        <!-- 必要的分页参数设置 -->
        <input type="hidden" id="TotalCount" value="{{=it.totalCount}}" />
    </script>
    <script type="text/javascript">
        $(function () {
            doSearch();
            //搜索
            $("#btnSearch").click(function () {
                doSearch();
            });
            $("body").keydown(function (event) {
                if (event.keyCode == "13") {
                    doSearch();
                }
            });
        });

        $("input[name='uCompanyName']").autocomplete({
            minLength: 1,
            source: function (request, response) {
                FlashPay.Util.Ajax({
                    url: '/Role/CompanySearch',
                    type: 'POST',
                    data: { companyName: $("input[name='uCompanyName']").val() },
                    success: function (res) {
                        if (res.success) {
                            if (res.data != null && res.data.length > 0) {
                                response($.map(res.data, function (item) {
                                    return {
                                        label: item.companyName,
                                        value: item.companyName,
                                        id: item.companyID
                                    }
                                }))
                            }
                        } else {
                            FlashPay.UI.Tip_warning("操作失败！" + res.errorMessage);
                        }
                    },
                    error: function (json) {
                        FlashPay.UI.Tip_warning("操作失败！请查看网络，请重试。");
                    }
                });
            }
        });

        function doSearch() {
            FlashPay.UI.Pager(".paging", { templateId: "templatePager", ajax: { url: '/User/GetList'} });
        }

        function Tip_success(word) {
            FlashPay.UI.Tip_success(word);
        }
    </script>
</body>
</html>